/*
 * PlayerStats.cpp
 *
 *  Created on: Oct 8, 2011
 *  Created by: Devin Manno
 *  Updated by: Nick James, Devin Manno
 *	Last Update: Nov 7, 2011
 */
#include "CharacterStats.h"
#include "PlayerStats.h"

/*
 * generateStats
 * Description: generates a random set of stats based on the player's class, pClass
 *      WARRIORS will get more strength, WIZARDS will get more intelligence, RANGERS
 *      will get more concentration. 20 points are distributed across strength,
 *      intelligence, concentration and agility.
 * Pre: pClass is the player's class.
 * Post: player's stats are generated and set to the values generated.
 * Returns: none
 */
void PlayerStats::generateStats(CharClass pClass){
        srand(time(NULL));
        short addTo = 0;

        switch(pClass) {
        case WARRIOR:
                while((agility + strength + intelligence + concentration) < startingPoints){
                        addTo = rand() % 6 + 1;         // random 1-6
                        if(addTo == 1)
                                agility++;
                        else if(addTo == 2)
                                strength++;
                        else if(addTo == 3)
                                intelligence++;
                        else if(addTo == 4)
                                concentration++;
                        else // 2/5 chance to increase strength
                                strength++;
                }
                break;
        case WIZARD:
                while((agility + strength + intelligence + concentration) < startingPoints){
                                        addTo = rand() % 6 + 1;         // random 1-6
                                        if(addTo == 1)
                                                agility++;
                                        else if(addTo == 2)
                                                strength++;
                                        else if(addTo == 3)
                                                intelligence++;
                                        else if(addTo == 4)
                                                concentration++;
                                        else // 2/5 chance to increase intelligence
                                                intelligence++;
                                }
                break;
        case RANGER:
                while((agility + strength + intelligence + concentration) < startingPoints){
                                        addTo = rand() % 6 + 1;         // random 1-6
                                        if(addTo == 1)
                                                agility++;
                                        else if(addTo == 2)
                                                strength++;
                                        else if(addTo == 3)
                                                intelligence++;
                                        else if(addTo == 4)
                                                concentration++;
                                        else // 2/5 chance to increase concentration
                                                concentration++;
                                }
                break;
        default: // should not happen, set main stats to -1 to show error
                agility = -1;
                strength = -1;
                intelligence = -1;
                concentration = -1;
                break;
        }
}

PlayerStats::PlayerStats(CharClass playerClass){
        experience = 0;
        generateStats(playerClass);
}

PlayerStats::PlayerStats(){
	experience = 0;
	actionPointsType = "";
}

PlayerStats::~PlayerStats() {
	// TODO Auto-generated destructor stub
}

// getters
int PlayerStats::getExp() const{
	return experience;
}

// setters
void PlayerStats::setPlayerStats(int agil, int str, int intel,
			int conc, int maxAP, int maxHP, int lvl, int HP,
			int AP, std::string &APType){
	setCharacterStats(agil, str, intel, conc, maxAP, maxHP, lvl, HP, AP);
	experience = 0;
	actionPointsType = APType;
}

void PlayerStats::setExp(int xp){
	experience = xp;
}

void PlayerStats::setActionPointsType(std::string apType){
	actionPointsType = apType;
}
